#ifndef utils_h
#define utils_h

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>

using namespace	std;
using namespace cv;

//Angulo en sexagesimal
double angleBetween( cv::Point pt1, cv::Point pt2, cv::Point pt0 );
int distanceBetween( cv::Point pt1, cv::Point pt2 );
double distanceBetweenF( cv::Point pt1, cv::Point pt2 );
cv::Point2f computeIntersect(Vec4i a, Vec4i b) ;
bool comparator(cv::Point2f a,cv::Point2f b);
bool comparatorRect(Rect a,Rect b);
void sortCorners(std::vector<cv::Point2f>& corners, cv::Point2f center);
bool cumpleRatio(int w, int h,double valor, double errorNeg,double errorPos);
bool esParalelogramo(vector<cv::Point2f> poligono,double error);
int * calcularHistograma(unsigned char* img_data, int w, int h);
int * calcularSumaCortesHorizontales(Mat img);
int * calcularSumaCortesVerticales(Mat img);
Mat perspectiva(Mat src, vector<cv::Point2f> corners,int rows,int cols,int k);
int horizontalCrosscut(Mat src,int row);
int * hallarMaximosMitad(int* funcion,int length,int width);
int * hallarTransiciones(int* funcion,int length);
void truncarHistograma(int * hist,int length, int threshold);
bool cumpleRatio(vector<cv::Point2f> poligono,double valor,double errorNeg,double errorPos);
void cerrarTodo();
void eliminarParalelas(vector<Vec4i> lines,vector<Vec4i> &lines2);
void agregarLineas(vector<vector<vector<cv::Point> > > &vectorLineas,vector<Vec4i>lines);
void convertirPoint2fToPoint(vector<Point2f> v1,vector<cv::Point> &v2);
void copyTo(Mat &dst,Mat src,Mat mask);
void dibujarImagen(System::Windows::Forms::PictureBox^ control, cv::Mat& grayImage );

#endif